<?php

namespace Biz\Criteria\Site;

use Lumen\Repository\Contracts\CriterionContract;

/**
 * IntroductionHasSiteCriterion.
 *
 * @license [http://www.85do.com] [杭州永奥网络科技有限公司]
 * @copyright Copyright (c) 2018-2026 Hangzhou Yongao Technology Co., Ltd. All rights reserved.
 */
class SiteFilterCriterion implements CriterionContract
{
    /**
     * @var mixed
     */
    protected $site_id;

    /**
     * UserSiteCriterion constructor.
     *
     * @param int $site_id
     */
    public function __construct(int $site_id)
    {
        $this->site_id = $site_id;
    }

    /**
     * Apply current criterion to the given query and return query.
     *
     * @param \Illuminate\Database\Eloquent\Model            $model
     * @param \Lumen\Repository\Contracts\RepositoryContract $repository
     *
     * @return \Illuminate\Database\Eloquent\Model
     */
    public function apply($model, $repository)
    {
        $model = $model->where('site_id', '=', $this->site_id);

        return $model;
    }
}
